﻿package export.monster
{
    import base.BaseMonster;
    
    import com.game.manager.AnimationManager;
    
    import export.bullet.EnemyMoveBullet;
    
    import export.bullet.RegionBullet;
    
    import flash.geom.Rectangle;
    
    
    public class Monster307 extends BaseMonster
    {
        public function Monster307()
        {
            super();
        }
        
        override protected function initBBDC():void
        {
            bbdc = AnimationManager.getAnimation("Monster304Action");
            bbdc.setAction("idle");
            bbdc.turnRight();
            bbdc.addCallBack(onEnterFrame, onActionOver);
            bodyContainer.addChild(bbdc);
        }
        
        override protected function initCollideArea():void
        {
            collideBox = new Rectangle(-25,-82,50,82);
            super.initCollideArea();
        }
        
        override protected function initAttribute():void
        {
            super.initAttribute();
            mavo.attackRange = 150;
        }
        
        override public function getActionHurt(action:String):int
        {
            switch (action)
            {
                case "attack1":
                    return super.getActionHurt(action);
                case "skill1":
                    return super.getActionHurt(action) * 2;
                case "skill2":
                    return super.getActionHurt(action) * 2;
            }
            return 0;
        }
        
        override protected function onEnterFrame(action:String, frameCount:int):void
        {
            switch (action)
            {
                case "attack1":
                    if(frameCount == 7)
                    {
                        var b:RegionBullet = new RegionBullet();
                        b.setOwner(this);
                        b.setHurt(getActionHurt("attack1"));
                        b.setDirect(bbdc.getDirect());
                        b.setCollideArea(20,-60,120 * bbdc.getDirect(),65);
                        b.setAction("Monster304Attack1");
                        b.setDestroyInCount(bbdc.frameLeft);
                        gc.gameScene.addChild(b);
                        magicBulletArray.push(b);
                    }
                    break;
                case "skill1":
                    if(frameCount == 4)
                    {
                        var b:RegionBullet = new RegionBullet();
                        b.setOwner(this);
                        b.setHurt(getActionHurt("skill1"));
                        b.setDirect(bbdc.getDirect());
                        b.setCollideArea(13,-105,140 * bbdc.getDirect(),110);
                        b.setAction("Monster304Attack1");
                        b.setDestroyInCount(8);
                        gc.gameScene.addChild(b);
                        magicBulletArray.push(b);
                    }
                    if(frameCount == 13)
                    {
                        var b:RegionBullet = new RegionBullet();
                        b.setOwner(this);
                        b.setHurt(getActionHurt("skill1"));
                        b.setDirect(bbdc.getDirect());
                        b.setCollideArea(50,-105,300 * bbdc.getDirect(),110);
                        b.setAction("Monster304Attack1");
                        b.setDestroyInCount(11);
                        gc.gameScene.addChild(b);
                        magicBulletArray.push(b);
                    }
                    break;
                case "skill2":
                    if(frameCount == 6)
                    {
                        for (var i:int = 0; i < 5; i++)
                        {
                            var bu:EnemyMoveBullet = new EnemyMoveBullet("Monster304Bullet1");
                            bu.setOwner(this);
                            bu.setHurt(getActionHurt("skill2"));
                            bu.setAction("Monster304Skill1");
                            bu.setDirect(bbdc.getDirect());
                            bu.setDistance(1000);
                            bu.setSpeed(0,15);
                            bu.setSpeedAdd(0,1);
                            bu.setPosition(getCollideCenter().x + 100 * i * bbdc.getDirect(), getCollideCenter().y - 500);
                            gc.gameScene.addChild(bu);
                            magicBulletArray.push(bu);
                        }
                    }
            }
        }
        
        override protected function beforeSkill1Start():Boolean
        {
            return this.hasTarget() && AUtils.GetDisBetweenTwoObj(this, this.curAttackTarget) < 300;
        }
        
        override protected function beforeSkill2Start():Boolean
        {
            return this.hasTarget() && AUtils.GetDisBetweenTwoObj(this,this.curAttackTarget) < 500;
        }
    }
}


/*package export.monster
{
	import base.BaseMonster;
	
	import export.bullet.SpecialEffectBullet;
	
	public class Monster307 extends BaseMonster 
    {

        public function Monster307()
        {
            this.attackBackInfoDict["hit1"] = {
                "hitMaxCount":1,
                "attackBackSpeed":[0, -2],
                "AttackInterval":4,
                "power":150,
                "attackKind":"physics"
            };
            this.attackBackInfoDict["hit2"] = {
                "hitMaxCount":100,
                "attackBackSpeed":[5, -5],
                "AttackInterval":999,
                "power":300,
                "attackKind":"physics"
            };
            this.isFly = true;
            this.setLostGravity();
        }
    
        override protected function beforeSkill1Start():Boolean
        {
            return this.hasTarget() && AUtils.GetDisBetweenTwoObj(this, this.curAttackTarget) < 350;
        }

        override protected function releSkill1():void
        {
            this.setInvincible(gc.frameClips * 1.5);
            this.setAction("hit2");
            var bb:SpecialEffectBullet = new SpecialEffectBullet("Monster307Bullet1");
            bb.y = this.hasTarget() ? this.curAttackTarget.y - 100 : this.y;
            bb.x = this.hasTarget() ? this.curAttackTarget.x - 100 : this.x;
            bb.setOwner(this);
            bb.setAction("hit2");
            gc.gameScene.addChild(bb);
            this.magicBulletArray.push(bb);
        }
		
		override protected function attackTarget():void
		{
            
            this.faceToTarget();
			this.setAction("hit1");
            this.speed.x = this.isRight ? 15 : -15;
            if(this.curAttackTarget)
            {
                this.speed.y = this.y < this.curAttackTarget.y ? 5 : -5;
            }
            else
            {
                this.speed.y = Math.round(-5 * Math.random());
            }
		}
        
        override public function isAttacking():Boolean
        {
            return this.curAction == "hit1" || this.curAction == "hit2";
        }

        override public function isCanMoveWhenAttack():Boolean
        {
            return this.curAction == "hit1" || this.curAction == "hit2";
        }
    }
}*/
